﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using XinGuanERP.Attributes.system;
using XinGuanERP.Models.Vo.business;
using XinGuanERP.Services.business.IServices;
using XinGuanERP.Utils;

namespace XinGuanERP.Controllers.business;

[DynamicApiController]
public class ProductStockController
{
    private readonly IProductStockService _productStockService;
    
    public ProductStockController(IProductStockService productStockService)
    {
        _productStockService = productStockService;
    }

    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil InProductStock(ProductStockVo productStockVo) =>
        ResultUtil.ok(_productStockService.InProductStock(productStockVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil OutProductStock(ProductStockVo productStockVo) =>
        ResultUtil.ok(_productStockService.OutProductStock(productStockVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil GetProductStockWithPage(int page, int pageSize,[FromQuery] ProductStockVo productStockVo) =>
        ResultUtil.ok(_productStockService.GetProductStockWithPage(page, pageSize, productStockVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil GetProductStockWithList() =>
        ResultUtil.ok(_productStockService.GetProductStockList());
}